package com.heima.wemedia.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.SensitiveDto;
import com.heima.model.wemedia.pojos.WmSensitive;
import com.heima.wemedia.service.WmSensitiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 朱安东
 * @version 1.0
 * @project leadnews-project
 * @date 2024/1/25 19:43:15
 */
@RestController
@RequestMapping("/api/v1/sensitive")
public class WmSensitiveController {
    @Autowired
    private WmSensitiveService wmSensitiveService;

    /**
     * 新增敏感词
     *
     * @param wmSensitive WM 敏感
     * @return {@link ResponseResult}
     */
    @PostMapping("/save")
    public ResponseResult insert(@RequestBody WmSensitive wmSensitive) {
        return wmSensitiveService.insert(wmSensitive);
    }

    /**
     * 敏感词分页查询
     *
     * @param sensitiveDto 灵敏DTO
     * @return {@link ResponseResult}
     */
    @PostMapping("/list")
    public ResponseResult PageQuery(@RequestBody SensitiveDto sensitiveDto){
        return wmSensitiveService.PageQuery(sensitiveDto);
    }

    /**
     * 修改敏感词
     *
     * @param wmSensitive WM 敏感
     * @return {@link ResponseResult}
     */
    @PostMapping("/update")
    public ResponseResult update(@RequestBody WmSensitive wmSensitive) {
        return wmSensitiveService.update(wmSensitive);
    }

    /**
     * 删除敏感词
     *
     * @param id 编号
     * @return {@link ResponseResult}
     */
    @DeleteMapping("/del/{id}")
    public ResponseResult deleteById(@PathVariable Integer id) {
        return wmSensitiveService.deleteById(id);
    }
}
